# /*
#  * @Descripttion: 
#  * @version: V1.0.0
#  * @Author: Maverick
#  * @Date: 2025-03-15 20:18:02
#  * @LastEditors: Maverick
#  * @LastEditTime: 2025-03-15 20:21:12
# make --always-make
#  */
SHELL=/bin/bash
OBJ = sqlisttest.o $(SRC_DIR)/sqlist.o
FILE_FILES:=$(wildcard *.cpp )
FILE_COUNT:=$(words $(FILE_FILES))
COUNTER:=0
REFCOUNTER:=0
REFER_SRC:=$(wildcard $(SRC_DIR)/*.cpp)
REFER_SRC_COUNT:=$(words $(REFER_SRC))

$(info SRC_DIR=$(SRC_DIR))
$(info OBJ=$(OBJ))
$(info REFER_SRC=$(REFER_SRC))
$(info REFER_SRC_COUNT=$(REFER_SRC_COUNT))

.PHONY:all
all:$(BIN_TEST)
$(BIN_TEST):$(OBJ)
	$(CC)  $(OBJ) $(CGTESTLDFLAGS)  -o $(BIN_TEST)
	sudo mv $(BIN_TEST) $(BUILD_DIR)
$(SRC_DIR)/%.o:$(SRC_DIR)/%.cpp
	$(eval REFCOUNTER := $(shell expr $(REFCOUNTER) + 1))
	$(eval PECENTAGEREF := $(shell echo "scale=2; ($(REFCOUNTER)/$(FILE_COUNT)) * 100 " | bc ))
	@echo -e $(GREEN)"$(TAG) [$(REFCOUNTER)/$(FILE_COUNT)] [$(PECENTAGEREF)]%  ,Compile at $<\n"$(RESET)
	@$(CC) $(CFLAGS) -c  $<  -o $@

%.o:%.cpp
	$(eval COUNTER := $(shell expr $(COUNTER) + 1))
	$(eval PECENTAGE := $(shell echo "scale=2 ; ($(COUNTER)/$(FILE_COUNT)) * 100 " | bc))
	@echo -e $(GREEN)"$(TAG)[$(COUNTER)/$(FILE_COUNT)] [$(PECENTAGE)]% ,Compile at $< \n"$(RESET)
	@$(CC) $(CGTESTFLAGS) -c  $<  -o $@
.PHONY:clean
clean:
	@sudo rm -rf  $(BUILD_DIR)/$(BIN_TEST) $(BUILD_DIR)/*.o
